package com.huoyun.car.action;

import java.util.List;

import com.huoyun.base.action.BaseAction;
import com.huoyun.car.bean.Car;
import com.huoyun.car.bean.NormallyTransportRoute;
import com.huoyun.car.model.NormallyTransportRouteModel;
import com.huoyun.car.service.CarService;
import com.huoyun.car.service.NormallyTransportRouteService;

/**
 * 常跑路线相关的action
 * @ClassName NormallyTransportRouteAction
 * @author ChengXin
 * @date 2012-12-16
 */
public class NormallyTransportRouteAction extends BaseAction 
{
	private static final long serialVersionUID = 1L;
	
	/**
	 * 一条常跑路线
	 * @author ChengXin
	 */
	private NormallyTransportRoute normallyTransportRoute;
	/**
	 * 管理"常跑路线"的service
	 * @author ChengXin
	 */
	private NormallyTransportRouteService normallyTransportRouteService;
	/**
	 * "常跑路线"列表
	 * @author ChengXin
	 */
	private List<NormallyTransportRouteModel> normallyTransportRouteModelList;
	/**
	 * 车辆列表
	 * 用于显示车牌号列表
	 */
	private List<Car> carList;
	/**
	 * 管理车辆的service
	 */
	private CarService carService;
	
	/**
	 * 为指定车辆添加一条新的常跑路线
	 * @return SUCCESS
	 * @author ChengXin
	 */
	public String addNormallyTransportRoute()
	{
		long userId = getLoginUser().getId();
		this.normallyTransportRoute.setUserId(userId);
		this.normallyTransportRouteService.save(this.normallyTransportRoute);
		
		return SUCCESS;
	}
	
	/**
	 * 获取当前用户的常规路线列表
	 * @return SUCCESS
	 * @author ChengXin
	 */
	public String getNormallyTransportRoutesForUser()
	{
		long userId = getLoginUser().getId();
		this.normallyTransportRouteModelList = normallyTransportRouteService.getModelListByUserId(userId);
		this.carList = carService.getCarList(userId);
		return SUCCESS;
	}
	
	/**
	 * 删除一条常跑路线
	 * @return SUCCESS
	 * @author ChengXin
	 */
	public String deleteNormalRoute()
	{
		long ntRouteId = Long.parseLong(getRequest().getParameter("ntRouteId"));
		this.normallyTransportRouteService.deleteRouteById(ntRouteId);
		
		return SUCCESS;
	}

	public NormallyTransportRoute getNormallyTransportRoute() {
		return normallyTransportRoute;
	}

	public void setNormallyTransportRoute(
			NormallyTransportRoute normallyTransportRoute) {
		this.normallyTransportRoute = normallyTransportRoute;
	}

	public NormallyTransportRouteService getNormallyTransportRouteService() {
		return normallyTransportRouteService;
	}

	public void setNormallyTransportRouteService(
			NormallyTransportRouteService normallyTransportRouteService) {
		this.normallyTransportRouteService = normallyTransportRouteService;
	}

	public List<NormallyTransportRouteModel> getNormallyTransportRouteModelList() {
		return normallyTransportRouteModelList;
	}

	public void setNormallyTransportRouteModelList(
			List<NormallyTransportRouteModel> normallyTransportRouteModelList) {
		this.normallyTransportRouteModelList = normallyTransportRouteModelList;
	}

	public List<Car> getCarList() {
		return carList;
	}

	public void setCarList(List<Car> carList) {
		this.carList = carList;
	}

	public CarService getCarService() {
		return carService;
	}

	public void setCarService(CarService carService) {
		this.carService = carService;
	}
}
